package com.project.controller;

import com.project.bean.PurchaseCarBean;
import com.project.service.IPurchaseCarService;
import com.project.util.InfoResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lyl
 * description:
 */
@RestController
@RequestMapping("purchaseCar")
@Api(tags = "采购预处理相关controller")
public class PurchaseCarController {
    @Autowired
    private IPurchaseCarService iPurchaseCarService;

    @GetMapping("showPurchaseCarByPage/{supplierId}/{userId}")
    private List<PurchaseCarBean> showPurchaseByPage(@PathVariable int supplierId, @PathVariable int userId) {
        return iPurchaseCarService.showPurchaseCarById(supplierId, userId);
    }

    @PostMapping("updatePurchaseNum/{supplierId}/{userId}/{productId}/{num}")
    private InfoResult updatePurchaseNum(@PathVariable int supplierId,
                                         @PathVariable int userId,
                                         @PathVariable int productId,
                                         @PathVariable int num) {
        return iPurchaseCarService.updatePurchaseNum(supplierId, userId, productId, num);
    }

    @PostMapping("purchaseProducts/{supplierId}/{userId}")
    private InfoResult purchaseProducts(@PathVariable int supplierId, @PathVariable int userId) {
        return iPurchaseCarService.purchaseProducts(supplierId, userId);
    }

}
